import React from 'react';
import { Link } from 'react-router-dom';
import { Breadcrumb } from 'antd';
import breadcrumbNameMap from './breadcrumbNameMap';
// const breadcrumbNameMap: Record<string, string> = {
//   '/welcome': '首页',
//   '/customer-access': '客户入网',
//   '/customer-access/newcustomers': '新增客户',
//   '/customer-access/batchimport': '批量导入',
// };

interface IProps {
  // setFormNavigation: (value: string | number) => void;
  props: any;
}

const BreadcrumbNavigation = (props: IProps) => {
  const { location } = props?.props;
  const pathSnippets = location.pathname.split('/').filter((i) => i);

  const extraBreadcrumbItems = pathSnippets.map((_, index) => {
    const url = `/${pathSnippets.slice(0, index + 1).join('/')}`;
    return (
      <Breadcrumb.Item key={url}>
        <Link to={url}>{breadcrumbNameMap[url]}</Link>
      </Breadcrumb.Item>
    );
  });

  const breadcrumbItems = [].concat(extraBreadcrumbItems);

  return (
    <>
      {document.body.clientWidth > 800 ? (
        <Breadcrumb
          style={{ display: 'flex', marginTop: '16px', marginLeft: '0px' }}
        >
          {breadcrumbItems}
        </Breadcrumb>
      ) : null}
    </>
  );
};

export default BreadcrumbNavigation;
